package com.lyun.typeHandler;

import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

/*

@MappedJdbcTypes(JdbcType.BIGINT)
@MappedTypes({String.class})
public class LongToStringTypeHandler extends BaseTypeHandler<Long> {

    @Override
    public void setNonNullParameter(PreparedStatement ps, int i, Long parameter, JdbcType jdbcType) throws SQLException {
        ps.setString(i, String.valueOf(parameter));
    }

    @Override
    public Long getNullableResult(ResultSet rs, String columnName) throws SQLException {
        String resultStr = rs.getString(columnName);
        if (resultStr != null) {
            return Long.valueOf(resultStr);
        } else {
            return null;
        }
    }

    @Override
    public Long getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
        String resultStr = rs.getString(columnIndex);
        if (resultStr != null) {
            return Long.valueOf(resultStr);
        } else {
            return null;
        }
    }

    @Override
    public Long getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
        String resultStr = cs.getString(columnIndex);
        if (resultStr != null) {
            return Long.valueOf(resultStr);
        } else {
            return null;
        }
    }

}
*/
